<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"></meta>
    <title>登录页</title>
    <link rel="stylesheet" href="layui/css/layui.css"></link>
    <link rel="stylesheet" href="layui/css/style.css"></link>
    <link rel="stylesheet" href="layui/css/templatemo_style.css"></link>	
    <link rel="icon" href="layui/images/face/0.gif"></link>
	<script src="layui/layui.js"></script>
</head>
<body 	style="width:100%;padding:0;margin:0;background-repeat: no-repeat;background-size:cover;background-image:url(layui/images/login.jpg)">
<!-- <div  class="layui-show" style="background:white;height:280px;width:400px;margin:8% 37.5%;border-radius: 20px;"></div> -->
<div class="login-main">
    <header class="layui-elip" ></header>
    <form class="form-horizontal templatemo-container templatemo-login-form-1 margin-bottom-30">
    	<h2 style="color:#5CACEE">武汉菱电软件版本控制系统</h2>
        <div class="layui-input-inline">
            <input type="text" name="username" lay-verify="required" placeholder="请输入账号" autocomplete="off"
                   class="layui-input"></input>
        </div>
        <div class="layui-input-inline">
            <input type="password" name="password" lay-verify="required" placeholder="请输入密码" autocomplete="off"
                   class="layui-input"></input>
        </div>
        <div class="layui-input-inline login-btn">
            <button lay-submit lay-filter="login" class="layui-btn" >登录</button>
        </div>
        <hr/>
        <!--<div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-primary">QQ登录</button>
        </div>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-normal">微信登录</button>
        </div>-->
       <!--  <p><a href="register.html" >立即注册</a><a href="#">忘记密码？</a></p> -->
    </form>
</div>
<script type="text/javascript">

	layui.use(['form','layer','jquery'], function () {
	    // 操作对象
	    var form = layui.form;
	    var $ = layui.jquery;
	    $("input[name='username']").focus();//聚焦输入框
	    form.on('submit(login)',function (data) {
	    	var username = $("input[name='username']").val();
	 	    var password = $("input[name='password']").val();
	 	    var object = {};
	 	    object['username'] = username;
	 	    object['password'] = password;
	 	    var json = JSON.stringify(object);
	        $.ajax({
	            url:'login',
	            contentType: "application/json;charset=utf-8",
	            data:json,
	            type:'post',
	            success:function (data) {  
	                if (data == '1'){
	                	layer.msg('用户名或密码错误');
	                }else if (data == '2'){
	                    layer.msg('用户名不存在');
	                }else if (data == '0'){
	                	location.href = "index.html";
	                }else if (data == '3'){
	                	layer.msg('用户已被软销户');
	                }else{
	                	 layer.msg('未知错误');
	                }
	            }
	        })
	        return false;
	    })
	
	});
</script>
</body>
</html>